function $addEvent(obj, type, handle) {
    function setHandler(obj, type, handler, wrapper) {
        obj.__hids = obj.__hids || [];
        var hid = "h" + window.__Hcounter++;
        obj.__hids.push(hid), window.__allHandlers[hid] = {
            "type": type,
            "handler": handler,
            "wrapper": wrapper
        };
    }
    function createDelegate(handle, context) {
        return function() {
            return handle.apply(context, arguments);
        };
    }
    if (!obj || !type || !handle) return;
    if (obj instanceof Array) {
        for (var i = 0, l = obj.length; i < l; i++) $addEvent(obj[i], type, handle);
        return;
    }
    if (type instanceof Array) {
        for (var i = 0, l = type.length; i < l; i++) $addEvent(obj, type[i], handle);
        return;
    }
    window.__allHandlers = window.__allHandlers || {}, window.__Hcounter = window.__Hcounter || 1;
    if (window.addEventListener) {
        var wrapper = createDelegate(handle, obj);
        setHandler(obj, type, handle, wrapper), obj.addEventListener(type, wrapper, !1);
    } else if (window.attachEvent) {
        var wrapper = createDelegate(handle, obj);
        setHandler(obj, type, handle, wrapper), obj.attachEvent("on" + type, wrapper);
    } else obj["on" + type] = handle;
}

function $delCookie(name, path, domain, secure) {
    var value = $getCookie(name);
    if (value != null) {
        var exp = new Date;
        exp.setMinutes(exp.getMinutes() - 1e3), path = path || "/", document.cookie = name + "=;expires=" + exp.toGMTString() + (path ? ";path=" + path : "") + (domain ? ";domain=" + domain : "") + (secure ? ";secure" : "");
    }
}

function $getBrowser() {
    var ua = navigator.userAgent.toLowerCase();
    return window.ActiveXObject ? "IE" + ua.match(/msie ([\d.]+)/)[1] : ua.indexOf("firefox") != -1 ? "Firefox" + ua.match(/firefox\/([\d.]+)/)[1] : ua.indexOf("chrome") != -1 ? "Chrome" + ua.match(/chrome\/([\d.]+)/)[1] : window.opera ? "Opera" + ua.match(/opera.([\d.]+)/)[1] : window.openDatabase ? "Safari" + (/version\/([\d.]+)/.test(ua) ? ua.match(/version\/([\d.]+)/)[1] : "weixin") : ua.replace(/\s*/g, "");
}

function $getCookie(name) {
    var reg = new RegExp("(^| )" + name + "(?:=([^;]*))?(;|$)"), val = document.cookie.match(reg);
    return val ? val[2] ? unescape(val[2]) : "" : null;
}

function $getQuery(name, url) {
    var u = arguments[1] || window.location.search, reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"), r = u.substr(u.indexOf("?") + 1).match(reg);
    return r != null ? r[2] : "";
}

function $getUin() {
    var uin = $getCookie("uin") || $getCookie("uin_cookie") || $getCookie("pt2gguin") || $getCookie("o_cookie") || $getCookie("luin") || $getCookie("buy_uin");
    return uin ? parseInt(uin.replace("o", ""), 10) : "";
}

function $isPostMessage() {
    return postMessage ? !0 : !1;
}

function $loadUrl(o) {
    function clear() {
        if (!el) return;
        el.onload = el.onreadystatechange = el.onerror = null, el.parentNode && el.parentNode.removeChild(el), el = null;
    }
    o.element = o.element || "script";
    var el = document.createElement(o.element);
    el.charset = o.charset || "utf-8", o.onBeforeSend && o.onBeforeSend(el), el.onload = el.onreadystatechange = function() {
        if (/loaded|complete/i.test(this.readyState) || navigator.userAgent.toLowerCase().indexOf("msie") == -1) o.onLoad && o.onLoad(), clear();
    }, el.onerror = function() {
        clear();
    }, el.src = o.url, document.getElementsByTagName("head")[0].appendChild(el);
}

function $makeUrl(data) {
    var arr = [];
    for (var k in data) arr.push(k + "=" + data[k]);
    return arr.join("&");
}

function $namespace(name) {
    for (var arr = name.split(","), r = 0, len = arr.length; r < len; r++) for (var i = 0, k, name = arr[r].split("."), parent = {}; k = name[i]; i++) i === 0 ? eval("(typeof " + k + ')==="undefined"?(' + k + '={}):"";parent=' + k) : parent = parent[k] = parent[k] || {};
}

function $randomInt(num1, num2) {
    return num2 == undefined && (num2 = num1, num1 = 0), Math.floor(Math.random() * (num2 - num1) + num1);
}

function $report(url) {
    $loadUrl({
        "url": url + (url.indexOf("?") == -1 ? "?" : "&") + Math.random(),
        "element": "img"
    });
}

function $setCookie(name, value, expires, path, domain, secure) {
    var exp = new Date, expires = arguments[2] || null, path = arguments[3] || "/", domain = arguments[4] || null, secure = arguments[5] || !1;
    expires ? exp.setMinutes(exp.getMinutes() + parseInt(expires)) : "", document.cookie = name + "=" + escape(value) + (expires ? ";expires=" + exp.toGMTString() : "") + (path ? ";path=" + path : "") + (domain ? ";domain=" + domain : "") + (secure ? ";secure" : "");
}

function $strTrim(str, code) {
    var argus = code || "\\s", temp = new RegExp("(^" + argus + "*)|(" + argus + "*$)", "g");
    return str.replace(temp, "");
}

window["PP.wg.mobilereport.time"] && window["PP.wg.mobilereport.time"].push(new Date), $namespace("ECC.cloud.report"), ECC.cloud.report = {
    "_w": window,
    "_d": document,
    "_r": document.referrer.replace("http://", "").replace("https://", ""),
    "_v": $getCookie("visitkey"),
    "_t": (new Date).getTime(),
    "_o": !0,
    "data": {
        "p": "buy.qq.com",
        "v": "",
        "m": "GET",
        "s": "200",
        "r": "",
        "stParam": "",
        "pvid": "",
        "ver": "2.2",
        "time": "",
        "project": "",
        "rt": window.screen.width + "*" + window.screen.height,
        "c": window.screen.colorDepth,
        "deadline": 24,
        "b": $getBrowser()
    },
    "locusInfo": "",
    "pvlog": {
        "stracepvlog": "http://dmtrack.buy.qq.com/pvlog/stracepvlog?",
        "savepvlog": "http://dmtrack.buy.qq.com/pvlog/savepvlog?"
    },
    "uin": $getUin(),
    "isPP": !1,
    "is51": !1,
    "isWangGou": !1,
    "isYixun": !1,
    "isWeiGou": !1,
    "cref": !1,
    "curDomain": "paipai.com"
};

try {
    ECC.cloud.report._lh = document.location.href;
} catch (e) {
    ECC.cloud.report._lh = document.createElement("a"), ECC.cloud.report._lh.href = "", ECC.cloud.report._lh = ECC.cloud.report._lh.href;
}

ECC.cloud.report._u = ECC.cloud.report._lh.replace("http://", "").replace("https://", ""), ECC.cloud.report._lt = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/.exec(ECC.cloud.report._lh.toLowerCase()) || [];

try {
    ECC.cloud.report._h = document.location.hostname;
} catch (e) {
    ECC.cloud.report._h = ECC.cloud.report._lt[2];
}

ECC.cloud.report.init = function() {
    var that = this;
    this.setInfo(), this.analyze(), this.script(), this.hasBindOnTouch || (this.hasBindOnTouch = !0, this.bind());
}, ECC.cloud.report.setInfo = function() {
    this.data.pvid = this._v + this._t + $randomInt(10);
    if (!this.check()) return;
    this.setCurDomain(), this.renewVK();
    if (!this._r) {
        var unpPvRefer = $getCookie("unp_pv_refer");
        unpPvRefer && (this._r = unpPvRefer.replace("http://", "").replace("https://", ""), this.cref = !0);
    }
    $setCookie("unp_pv_refer", ECC.cloud.report._u, "52560000", "", this.curDomain), this.data.r = encodeURIComponent(this._r), this.data.time = this._t, this.data.stParam = "visitkey:" + this._v + "|uin:" + this.uin, this._lh.indexOf("error/40x") != -1 && (this.data.s = 400), this._lh.indexOf("error/50x") != -1 && (this.data.s = 500);
    if (this.uin) {
        var buyUin = $getCookie("buy_uin");
        this.uin != buyUin && $setCookie("buy_uin", this.uin, "52560000", "", this.curDomain);
    }
}, ECC.cloud.report.check = function() {
    var host = this._h, isBBC = /^(\w+\.)*buy\.qq\.com$/.test(host), isSP = /^(\w+\.)*shop\.qq\.com$/.test(host), isWeiGou = /^(\w+\.)*weigou\.qq\.com$/.test(host), isInfo = /^paipai\.(((lady|digi)\.qq\.com)|ellechina\.com|pchouse\.com\.cn)$/.test(host), isQQMail = /^(\w+\.)*mail\.qq\.com$/.test(host), isWangGou = /^(\w+\.)*wanggou\.com$/.test(host), isYixun = /^(\w+\.)*yixun\.com$/.test(host), isLvRen = /^(\w+\.)*lvren\.com$/.test(host), isQQ = /^(\w+\.)*qq\.com$/.test(host) && !isBBC && !isSP && !isInfo && !isWeiGou, isPP = /^(\w+\.)*paipai\.com$/.test(host), isTP = /^(\w+\.)*tenpay\.com$/.test(host), is51 = /^(\w+\.)*51buy\.com$/.test(host), isQO = /^www\.qolala\.com$/.test(host);
    this.isPP = isPP, this.is51 = is51, this.isWangGou = isWangGou, this.isYixun = isYixun, this.isWeiGou = isWeiGou, $setCookie("g_pvid", this.data.pvid, "", "", isPP ? "paipai.com" : "qq.com");
    if (!isQQ && !isBBC && !isPP && !isTP && !isSP && !is51 && !isYixun && !isInfo && !isQO && !isWangGou && !isLvRen && !isWeiGou || isTP && isQQBuy != 1 || isQQ && !isQQMail && !window.AIOPAGE) this._o = !1;
    return this._o;
}, ECC.cloud.report.setCurDomain = function() {
    this.is51 && (this.curDomain = "51buy.com"), this.isYixun && (this.curDomain = "yixun.com"), this.isWangGou && (this.curDomain = "wanggou.com"), this.isPP && (this.curDomain = "paipai.com"), this.isWeiGou && (this.curDomain = "qq.com");
}, ECC.cloud.report.renewVK = function() {
    this._v = $getCookie("visitkey");
}, ECC.cloud.report.renewStParam = function() {
    this.renewVK(), !this.uin && (this.uin = $getUin());
    if (!this.uin) {
        var buyUin = $getCookie("buy_uin");
        this.uin = buyUin;
    }
    this.data.stParam = "visitkey:" + this._v + "|uin:" + this.uin;
}, ECC.cloud.report.pv = function(pvInfo) {
    if (!this._o) return;
    this.data.v = this.parseObj(pvInfo), this.doReport("pv");
}, ECC.cloud.report.trace = function(opt) {
    if (!this._o) return;
    typeof opt == "object" ? this.data.v = this.parseObj(opt, "click") : this.data.v = opt, this.doReport("click");
}, ECC.cloud.report.doReport = function(type) {
    var that = this;
    this.pvType = type, !$getCookie("visitkey") || !document.getElementById("syn_vk_iframe") ? this.synPPVisitKey() : (ECC.cloud.report.renewStParam(), $report(ECC.cloud.report.pvlog.stracepvlog + $makeUrl(ECC.cloud.report.data)));
}, ECC.cloud.report.pipe = function(url) {
    url && (url.indexOf("?") < 0 && (url += "?"), this.renewStParam(), $report(url + "&" + $makeUrl(this.data)));
}, ECC.cloud.report.parseObj = function(obj, type) {
    var report = [];
    type == "click" && report.push("locus:" + this.locusInfo), this.cref && report.push("cref:1");
    for (var key in obj) {
        if (key == "p") {
            this.data.p = obj.p, this.setPvlog(obj.p);
            continue;
        }
        report.push(key + ":" + obj[key]);
    }
    return report.join("|");
}, ECC.cloud.report.setPvlog = function(p) {
    if (p == "search.51buy.com" || p == "51buy.com") this.pvlog = {
        "stracepvlog": "http://dmtrack.buy.qq.com/pvlog/stracepvlog?",
        "savepvlog": "http://dmtrack.buy.qq.com/pvlog/savepvlog?"
    }; else if (p == "paipai.com" || p == "aio.com" || p == "s.wanggou.com" || p == "m.wanggou.com") this.pvlog = {
        "stracepvlog": "http://dmtrack.paipai.com/pvlog/stracepvlog?",
        "savepvlog": "http://dmtrack.paipai.com/pvlog/savepvlog?"
    };
}, ECC.cloud.report.bind = function() {
    function getVP() {
        var ua = navigator.userAgent.toLowerCase(), browsers = {
            "weixin": /micromessenger/,
            "mqq": /qq\/([\d\.]+)*/
        }, temp = "other";
        for (var i in browsers) if (browsers[i].test(ua)) {
            temp = i;
            break;
        }
        return that._vp = temp, temp;
    }
    return;
    var that;
}, ECC.cloud.report.locus = function(tar) {
    if (!this._o) return;
    var locus = [], toUrl = "";
    while (tar && tar.tagName != "BODY" && tar.tagName != "HTML") if (tar.tagName == "TBODY" || tar.tagName == "THEAD") tar = tar.parentNode; else {
        tar.getAttribute && !toUrl && (toUrl = tar.getAttribute("tourl") || tar.tourl || ""), tar.tagName == "A" && !toUrl && (toUrl = tar.href);
        if (toUrl) {
            toUrl = $strTrim(toUrl);
            if (toUrl.indexOf("javascript:") == 0) toUrl = ""; else {
                var now = this._u.split("#")[0], cur = toUrl.replace("http://", "").replace("https://", "").split("#")[0];
                now == cur && (toUrl = "");
            }
        }
        locus.push(tar.tagName + ":" + this.locusIndex(tar)), tar = tar.parentNode;
    }
    if (locus.length > 0) {
        var trace = locus.reverse().join("-");
        /A|IMG|INPUT|BUTTON|SELECT/.test(trace) && trace.indexOf("CUSTOM:0") !== 0 && (this.locusInfo = this.locusZip(trace), this.data.project = encodeURIComponent(toUrl));
    }
}, ECC.cloud.report.locusIndex = function(lm) {
    var cur = lm, index = 0;
    while (cur = cur.previousSibling) lm.tagName == cur.tagName && index++;
    return index;
}, ECC.cloud.report.locusZip = function(trace) {
    return trace.replace(/BUTTON/g, "0").replace(/CUSTOM/g, "1").replace(/DIV/g, "2").replace(/IMG/g, "3").replace(/INPUT/g, "4").replace(/SELECT/g, "5").replace(/SPAN/g, "6").replace(/UL/g, "7").replace(/LI/g, "8").replace(/OL/g, "9");
}, ECC.cloud.report.analyze = function() {
    $getQuery("zxtj") === "true" ? $setCookie("g_tj", "zxtj", "", "", this.isPP ? "paipai.com" : "qq.com") : $getQuery("zxtj") === "false" && $delCookie("g_tj", "", this.isPP ? "paipai.com" : "qq.com"), $getCookie("g_tj") === "zxtj" && $loadUrl({
        "url": "http://static.gtimg.com/js/version/2011/11/bbc.cloud.analyze.20111110.js"
    });
}, ECC.cloud.report.sampling = function() {
    return !0;
}, ECC.cloud.report.setUin = function(info) {
    if (!this._o) return;
    if (info.uin) {
        var buyUin = $getCookie("buy_uin");
        info.uin != buyUin && $setCookie("buy_uin", info.uin, "52560000", "", this.curDomain);
    }
}, ECC.cloud.report.script = function() {
    if (!this._o) return;
    try {
        var all = document.body.getElementsByTagName("script");
        for (var i = 0, len = all.length; i < len; i++) {
            var item = all[i];
            if (item.id && item.id.indexOf("legos:") == 0) {
                var name = item.getAttribute("name"), ver = item.getAttribute("ver"), cgi = name, type = 1, code = 0, time = 0;
                window[cgi + ".time"] && window[cgi + ".time"].length > 2 && (time = window[cgi + ".time"][1] - window[cgi + ".time"][0]), cgi += "-" + ver, window[name] ? window[name] != ver && (type = 2, code = 1) : (type = 2, code = 5), (type == 1 && $randomInt(10) < 2 || type == 2) && $report("http://c.isdspeed.qq.com/code.cgi?domain=static.gtimg.com&cgi=" + cgi + "&type=" + type + "&code=" + code + "&time=" + time + "&rate=" + 5);
            }
        }
    } catch (e) {}
}, ECC.cloud.report.loadPaipaiVK = function() {
    var tempIframe, visitkey = $getCookie("visitkey") ? $getCookie("visitkey") : "";
    $isPostMessage() ? ((tempIframe = document.getElementById("load_ppvk_ifr")) || (tempIframe = document.createElement("iframe"), tempIframe.id = "load_ppvk_ifr", tempIframe.style.display = "none", document.getElementsByTagName("body")[0].appendChild(tempIframe)), tempIframe.src = "http://www.paipai.com/iframe/vk_iframe.shtml?visitkey=" + visitkey + "&_t=" + Math.random()) : $loadUrl({
        "url": "http://party.paipai.com/tws64/m/pvlog/set_visitkey?visitkey=" + visitkey + "&callback=ECC.cloud.setparams.setUnifyVkCallBack"
    });
}, ECC.cloud.report.synPPVisitKey = function() {
    function curDomain() {
        var curDom = document.domain;
        return that.is51 && (curDom = "51buy.com"), that.isYixun && (curDom = "yixun.com"), that.isWangGou && (curDom = "wanggou.com"), that.isPP && (curDom = "paipai.com"), curDom;
    }
    function onPPVKMsg(e) {
        var data = e.data || "", origin = e.origin;
        data = data.split("="), origin.indexOf("paipai.com") > -1 && data[0] && data[0] == "visitkey" && ($setCookie("visitkey", data[1], "52560000", "", curDomain()), ECC.cloud.report.renewStParam(), (ECC.cloud.report.pvType == "pv" || ECC.cloud.report.pvType == "click") && $report((ECC.cloud.report.pvType == "pv" ? ECC.cloud.report.pvlog.savepvlog : ECC.cloud.report.pvlog.stracepvlog) + $makeUrl(ECC.cloud.report.data)), that.hasBindOnTouch || (that.hasBindOnTouch = !0, that.bind()));
    }
    var tempIframe, visitkey = $getQuery("visitkey"), that = this;
    (tempIframe = document.getElementById("syn_vk_iframe")) || ($addEvent(window, "message", onPPVKMsg), tempIframe = document.createElement("iframe"), tempIframe.id = "syn_vk_iframe", tempIframe.style.display = "none", tempIframe.src = "http://www.paipai.com/mobile/synvisitkey.html" + (visitkey ? "?visitkey=" + visitkey : ""), document.getElementsByTagName("body")[0].appendChild(tempIframe));
}, ECC.cloud.report.init(), $namespace("ECC.cloud.setparams"), ECC.cloud.setparams.setUnifyVkCallBack = function(info) {
    info.visitkey && info.visitkey != $getCookie("visitkey") && ECC.cloud.report.curDomain != "paipai.com" && $setCookie("visitkey", info.visitkey, "52560000", "", ECC.cloud.report.curDomain), ECC.cloud.report.renewStParam(), $report((ECC.cloud.report.pvType == "pv" ? ECC.cloud.report.pvlog.savepvlog : ECC.cloud.report.pvlog.stracepvlog) + $makeUrl(ECC.cloud.report.data));
}, ECC.cloud.setparams.getUnifyVkCallBack = function(info) {
    if (info.visitkey) {
        $setCookie("visitkey", info.visitkey, "52560000", "", ECC.cloud.report.curDomain);
        var curStamp = parseInt((new Date).getTime() / 1e3);
        $setCookie(ECC.cloud.report.checkTime, curStamp, "52560000", "", ECC.cloud.report.curDomain);
    }
    ECC.cloud.report.loadPaipaiVK();
}, window["PP.wg.mobilereport"] = "21948:20140325:20140327112020", window["PP.wg.mobilereport.time"] && window["PP.wg.mobilereport.time"].push(new Date);